package com.cxyd.common;

public class RestResponse {
    private Integer status;
    private String msg;
    private Object obj;

    private RestResponse() {
    }

    public static RestResponse build() {
        return new RestResponse();
    }

    /**
     * 成功返回结果
     *
     * @param data 获取的数据
     */
    public static RestResponse ok(Object data) {
        return new RestResponse(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data);
    }

    /**
     * 成功返回结果
     *
     * @param data 获取的数据
     */
    public static RestResponse ok(String message,Object data) {
        return new RestResponse(ResultCode.SUCCESS.getCode(), message, data);
    }

    public static RestResponse error(String msg, Object obj) {
        return new RestResponse(500, msg, obj);
    }

    public static RestResponse error(String msg) {
        return new RestResponse(500, msg, null);
    }
    public static RestResponse error(Integer code,String msg) {
        return new RestResponse(code, msg,null);
    }

    public RestResponse(Integer status, String msg, Object obj) {
        this.status = status;
        this.msg = msg;
        this.obj = obj;
    }

    public Integer getStatus() {

        return status;
    }

    public RestResponse setStatus(Integer status) {
        this.status = status;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public RestResponse setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Object getObj() {
        return obj;
    }

    public RestResponse setObj(Object obj) {
        this.obj = obj;
        return this;
    }
}
